import http from '../index'

// 分页获取线路
export const getLines = ({ ascended = null, current = null, size = null, sortFieldName = null, status = null, lineName = null, outletsSid = null }) => {
    return http.get("lines", { ascended, current, size, sortFieldName, status, lineName, outletsSid })
}

// 根据sid获取线路
export const getLineDetail = ({ sid }) => {
    return http.get("lines/" + sid)
}

// 根据线路SID查询线路配置信息
export const getLineConfigs = ({ sid }) => {
    return http.get("lines/" + sid + '/configs')
}

// 根据线路SID查询线路绑定的提货企业
export const getLineEntdlvs = ({ sid }) => {
    return http.get("lines/" + sid + '/entdlv-list')
}

// 根据SID查询线路是否有车辆绑定
export const getLineHasCar = ({ sid }) => {
    return http.get("lines/" + sid + '/has-car')
}

// 根据线路SID查询线路绑定的提货员
export const getLineUsers = ({ sid }) => {
    return http.get("lines/" + sid + '/users')
}

// 新增线路
export const addLine = ({ config, endDistrictCode, endLatitude, endLongitude, estimatedDuration, lineName, outletsSid, routeDistrictCode, startDistrictCode, startLatitude, startLongitude, deliveryType = null, entdlvSid = null, pickerSids = null, note = null, status = null }) => {
    return http.post("lines", { config, endDistrictCode, endLatitude, endLongitude, estimatedDuration, lineName, outletsSid, routeDistrictCode, startDistrictCode, startLatitude, startLongitude, deliveryType, entdlvSid, pickerSids, note, status })
}

// 修改线路
export const editLine = ({ sid, config, endDistrictCode, endLatitude, endLongitude, estimatedDuration, lineName, outletsSid, routeDistrictCode, startDistrictCode, startLatitude, startLongitude, deliveryType = null, entdlvSid = null, pickerSids = null, note = null, status = null }) => {
    return http.put("lines/" + sid, { config, endDistrictCode, endLatitude, endLongitude, estimatedDuration, lineName, outletsSid, routeDistrictCode, startDistrictCode, startLatitude, startLongitude, deliveryType, entdlvSid, pickerSids, note, status })
}

// 批量删除线路
export const delLines = ({ sidList }) => {
    return http.put("lines/delete", { sidList })
}

// 根据sid启用-停用线路
export const changeLineStatus = ({ sid }) => {
    return http.put("lines/" + sid + '/status')
}